<?php
namespace app\go\controller;


class tbController extends \app\base\controller\BaseController {
	


  public function itemiid(){
  	  $id=$this->arg('id');
      if(!is_numeric($id)){ exit('error');}
	  include CONFIG_PATH . 'siteconfig.php';
	   $zhuan= new \ZhiCms\ext\Zhuan;
	   $tbk= new \ZhiCms\ext\Tbk;
	   $agent=self::agent("y");
	   $result=$zhuan->zhicms($Siteinfo['apiurl'],$Siteinfo['code'],$id);
	   if($result['code']==0){
		  exit($result['r']);	
		}
		$url=$result['t']['result']['data']["coupon_click_url"];
  if(!$result['t']['result']['data']["coupon_info"]){
	$url=$result['t']['result']['data']["item_url"];   
   }
	   if($agent==2){
		$info=$tbk->getinfotkl($Siteinfo['appkey'],$Siteinfo['secretKey'],$id,$url);   
		$this->biaoti=$info['bt'];   
		$this->taokouling=$info['tkl'];  
		$this->display(); 
       exit;		
	   }
	  $this->redirect($url);  
  }
      //判断浏览器
    public function agent($lock){
      if($lock=='y'){
        $user_agent = $_SERVER['HTTP_USER_AGENT'];
        if (strpos($user_agent, 'MicroMessenger') === false) {
             $agent="1"; //非微信
        } else {
            $agent="2"; //微信
        }

        return $agent;
      }
    }

}